package edu.towson.cosc603.coffeemaker;

import junit.framework.TestCase;

public class InventoryTest extends TestCase {

	private CoffeeMaker cm;
	private Inventory i;
	private Recipe r1;
	
	public void setUp() throws Exception {
		cm = new CoffeeMaker();
		i = cm.checkInventory();

		r1 = new Recipe();
		r1.setName("Coffee");
		r1.setPrice(50);
		r1.setAmtCoffee(6);
		r1.setAmtMilk(1);
		r1.setAmtSugar(1);
		r1.setAmtChocolate(1);
	}

	public void tearDown() throws Exception {
		cm = null;
		i = null;
		r1 = null;
	}

	/*
	 * Test the constructor to make sure it 
	 * initialized all values to 15. This
	 * also tests the set methods for > 0
	 */

	public void testInventory() {
		assertEquals("Coffee: 15\n" + "Milk: 15\n" + "Sugar: 15\n" + "Chocolate: 15\n", i.toString());
	}

	/*
	 * Test getChocolate to make sure it returns 15
	 */

	public void testGetChocolate() {
		assertEquals(15, i.getChocolate());
	}

	/*
	 * Test setChocolate to 0, should return 0
	 */

	public void testSetChocolate1() {
		i.setChocolate(0);
		assertEquals(0, i.getChocolate());
	}

	/*
	 * Test setChocolate to -10, should return 0
	 */

	public void testSetChocolate2() {
		i.setChocolate(-10);
		assertEquals(0, i.getChocolate());
	}

	/*
	 * Test getCoffee, should return 15
	 */

	public void testGetCoffee() {
		assertEquals(15, i.getCoffee());
	}

	/*
	 * Test setCoffee to -10, should
	 * return 0
	 */

	public void testSetCoffee1() {
		i.setCoffee(-10);
		assertEquals(0, i.getCoffee());
	}

	/*
	 * Test setCoffee to 0, should
	 * return 0
	 */

	public void testSetCoffee2() {
		i.setCoffee(0);
		assertEquals(0, i.getCoffee());
	}

	/*
	 * Test getMilk, should return 15
	 */

	public void testGetMilk() {
		assertEquals(15, i.getMilk());
	}

	/*
	 * Test setMilk to -10, should
	 * return 0
	 */

	public void testSetMilk1() {
		i.setMilk(-15);
		assertEquals(0, i.getMilk());
	}

	/*
	 * Test setMilk to 0, should
	 * return 0
	 */

	public void testSetMilk2() {
		i.setMilk(0);
		assertEquals(0, i.getMilk());
	}

	/*
	 * Test getSugar, should
	 * return 15
	 */

	public void testGetSugar() {
		assertEquals(15, i.getSugar());
	}

	/*
	 * Test setSugar to -15, should
	 * return 0
	 */

	public void testSetSugar1() {
		i.setSugar(-15);
		assertEquals(0, i.getSugar());
	}

	/*
	 * Test setSugar to 0, should
	 * return 0
	 */

	public void testSetSugar2() {
		i.setSugar(0);
		assertEquals(0, i.getSugar());
	}

	/*
	 * Test enoughIngredients, should return false
	 */

	public void testEnoughIngredients_Coffee1() {
		r1.setAmtCoffee(60);		
		assertFalse(i.enoughIngredients(r1));
	}
	
	/*
	 * Test enoughIngredients, should return true
	 */

	public void testEnoughIngredients_Coffee2() {
		r1.setAmtCoffee(6);		
		assertTrue(i.enoughIngredients(r1));
	}

	/*
	 * Test enoughIngredients, should return false
	 */

	public void testEnoughIngredients_Milk1() {
		r1.setAmtMilk(100);
		assertFalse(i.enoughIngredients(r1));
	}

	/*
	 * Test enoughIngredients, should return true
	 */

	public void testEnoughIngredients_Milk2() {
		r1.setAmtMilk(1);
		assertTrue(i.enoughIngredients(r1));
	}

	/*
	 * Test enoughIngredients, should return false
	 */

	public void testEnoughIngredients_Sugar1() {
		r1.setAmtSugar(100);
		assertFalse(i.enoughIngredients(r1));
	}

	/*
	 * Test enoughIngredients, should return true
	 */

	public void testEnoughIngredients_Sugar2() {
		r1.setAmtSugar(1);
		assertTrue(i.enoughIngredients(r1));
	}

	/*
	 * Test enoughIngredients, should return false
	 */

	public void testEnoughIngredients_Chocolate1() {
		r1.setAmtChocolate(100);
		assertFalse(i.enoughIngredients(r1));
	}

	/*
	 * Test enoughIngredients, should return true
	 */

	public void testEnoughIngredients_Chocolate2() {
		r1.setAmtChocolate(1);
		assertTrue(i.enoughIngredients(r1));
	}
}
